package com.hjm.java.sql;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class HJMHelper  extends SQLiteOpenHelper {

    // 私有的静态实例，延迟初始化
    private static volatile HJMHelper instance;

    // 获取单例实例的方法
    public static synchronized HJMHelper getInstance(Context context) {
        if (instance == null) {
            synchronized (HJMHelper.class) {
                if (instance == null) {
                    instance = new HJMHelper(context.getApplicationContext());
                }
            }
        }
        return instance;
    }
    public HJMHelper(Context context) {
        super(context, "hjm.app.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE img(id INTEGER PRIMARY KEY, img BLOB)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("CREATE TABLE img(id INTEGER PRIMARY KEY, img BLOB)");
    }
}
